package com.gel.aiagent.tools;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;

import java.io.IOException;

/*网页抓取*/
public class WebScrapingTool {
    @Tool(description = "Scrape the content of a web page")
    public String scrapeWebPage(@ToolParam(description = "URL 0f the web Page to scrape") String url) {
        // Implement web scraping logic here
        try {
            Document document = Jsoup.connect(url).get();
            return document.html();
        } catch (IOException e) {
           return "Error scraping web page"+e.getMessage();
        }
    }
}
